package com.ruoyi.web.controller.webgroup;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.webgroup.ClockCount;
import com.ruoyi.system.domain.webgroup.DailyList;
import com.ruoyi.system.domain.webgroup.GeneralList;
import com.ruoyi.system.domain.webgroup.WeeklyList;
import com.ruoyi.system.webgroupservcie.ClockCountService;
import com.ruoyi.system.webgroupservcie.ClockService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.parameters.P;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping("web/query")
public class QueryForDataController extends BaseController {
    @Autowired
    private ClockCountService clockCountService;
    @Autowired
    private ClockService clockService;

    /**
     * 日排行榜
     * @param dailyList
     * @return
     */
    @GetMapping("/dailyList")
    public TableDataInfo list(DailyList dailyList)
    {
        startPage();
        List<DailyList> list = clockService.selectDailyList(dailyList);
        return getDataTable(list);
    }

    /**
     * 修改某个数据项
     */
    @GetMapping(value = "/{dailyListId}")
    public AjaxResult getInfo(@PathVariable("dailyListId") Integer dailyListId)
    {
        return AjaxResult.success(clockService.selectWebDailyListByDailyListId(dailyListId));
    }


    /**
     * 日榜删除
     */
    @DeleteMapping("/{dailyListIds}")
    public AjaxResult remove(@PathVariable Integer[] dailyListIds)
    {
        return toAjax( clockService.deleteWebDailyListByDailyListIds(dailyListIds));
    }


    /**
     * 日榜新增
     * @param DailyList
     * @return
     */
    @PostMapping
    public AjaxResult add(@RequestBody DailyList DailyList)
    {
        return toAjax(clockService.insertWebDailyList(DailyList));
    }

    /**
     * 周排行榜
     * @param weeklyList
     * @return
     */
    @GetMapping("/weeklyList")
    public TableDataInfo list(WeeklyList weeklyList)
    {
        startPage();
        List<WeeklyList> list = clockService.selectWeeklyListList(weeklyList);
        return getDataTable(list);
    }


    /**
     * 总排行榜
     * @param generalList
     * @return
     */
    @GetMapping("/generalList")
    public TableDataInfo list(GeneralList generalList)
    {
        startPage();
        List<GeneralList> list = clockService.selectGeneralListList(generalList);
        return getDataTable(list);
    }

    /**
     * 根据id获取详细信息
     * 总排行榜
     * @param generalListId
     * @return
     */
    //@PreAuthorize("@ss.hasPermi('system:list:query')")
    @GetMapping(value = "/generalList/{generalListId}")
    public AjaxResult getInfoGeneral(@PathVariable("generalListId") Integer generalListId)
    {
        return AjaxResult.success(clockService.selectWebGeneralListByGeneralListId(generalListId));
    }

    /**
     * 新增功能
     * 总排行榜
     * @param webGeneralList
     * @return
     */
    //@PreAuthorize("@ss.hasPermi('system:list:add')")
    //@Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping("/generalList")
    public AjaxResult add(@RequestBody GeneralList webGeneralList)
    {
        return toAjax(clockService.insertWebGeneralList(webGeneralList));
    }

    /**
     * 修改
     * 总排行榜
     * @param webGeneralList
     * @return
     */
    //@PreAuthorize("@ss.hasPermi('system:list:edit')")
    //@Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping("/generalList")
    public AjaxResult edit(@RequestBody GeneralList webGeneralList)
    {
        return toAjax(clockService.updateWebGeneralList(webGeneralList));
    }

    /**
     * 删除【请填写功能名称】
     */
    //@PreAuthorize("@ss.hasPermi('system:list:remove')")
    //@Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/generalList/{generalListIds}")
    public AjaxResult removeGeneralListIds(@PathVariable Integer[] generalListIds)
    {
        return toAjax(clockService.deleteWebGeneralListByGeneralListIds(generalListIds));
    }

}
